﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:sys="clr-namespace:System;assembly=mscorlib"
                    xmlns:shell="clr-namespace:System.Windows.Shell;assembly=PresentationFramework"
                    xmlns:theme="clr-namespace:VividThemes.Controls.Primitives">

 <ResourceDictionary.MergedDictionaries>
  <ResourceDictionary Source="pack://application:,,,/VividThemes;Component/Themes/MotifColors.xaml" />
  <ResourceDictionary Source="pack://application:,,,/VividThemes;Component/Themes/UX.xaml" />
 </ResourceDictionary.MergedDictionaries>

 <sys:Double x:Key="HorizontalScrollBarHeight">13</sys:Double>
 <sys:Double x:Key="VerticalScrollBarWidth">13</sys:Double>
 <sys:Double x:Key="HorizontalScrollBarButtonWidth">11</sys:Double>
 <sys:Double x:Key="VerticalScrollBarButtonWidth">11</sys:Double>
 <sys:Double x:Key="HorizontalScrollBarButtonHeight">11</sys:Double>
 <sys:Double x:Key="VerticalScrollBarButtonHeight">11</sys:Double>

 <Style x:Key="ButtonFocusVisual">
  <Setter Property="Control.Template">
   <Setter.Value>
    <ControlTemplate>
     <Rectangle StrokeThickness="1"
                Stroke="{StaticResource ThemeActiveBrush}"
                SnapsToDevicePixels="true"
                Margin="-3" />
    </ControlTemplate>
   </Setter.Value>
  </Setter>
 </Style>

 <Style x:Key="BaseButtonStyle"
        TargetType="{x:Type ButtonBase}"
        BasedOn="{StaticResource BaseFrameworkElementStyle}">
  <Setter Property="OverridesDefaultStyle"
          Value="True" />
  <Setter Property="SnapsToDevicePixels"
          Value="True" />
  <Setter Property="FocusVisualStyle"
          Value="{StaticResource ButtonFocusVisual}" />
  <Setter Property="Background"
          Value="{StaticResource ThemeControlBrush}" />
  <Setter Property="Foreground"
          Value="{StaticResource ThemeControlTextBrush}" />
  <Setter Property="BorderBrush"
          Value="{x:Static theme:MotifBorderDecorator.MotifBorderBrush}" />
  <Setter Property="BorderThickness"
          Value="1" />
  <Setter Property="HorizontalAlignment"
          Value="{StaticResource uxButtonHorizontalAlignment}" />
  <Setter Property="VerticalAlignment"
          Value="{StaticResource uxButtonVerticalAlignment}" />
  <Setter Property="HorizontalContentAlignment"
          Value="Center" />
  <Setter Property="VerticalContentAlignment"
          Value="Center" />
  <Setter Property="Content"
          Value="{Binding Command.Name, RelativeSource={RelativeSource Self}}" />
  <Setter Property="ToolTip"
          Value="{Binding Command.Text, RelativeSource={RelativeSource Self}}" />
  <Setter Property="MinWidth"
          Value="{StaticResource uxButtonMinWidth}" />
  <Setter Property="MinHeight"
          Value="{StaticResource uxButtonMinHeight}" />
  <Setter Property="Padding"
          Value="{StaticResource uxButtonPadding}" />
  <Setter Property="Template">
   <Setter.Value>
    <ControlTemplate TargetType="{x:Type ButtonBase}">
     <Grid>
      <theme:MotifBorderDecorator x:Name="DefaultBorder"
                                    BorderStyle="ThinPressed"
                                    Background="{TemplateBinding Background}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    SnapsToDevicePixels="True"
                                    Margin="-3"
                                    Visibility="Collapsed" />
      <theme:MotifBorderDecorator x:Name="ContentContainer"
                                    BorderStyle="ThinRaised"
                                    Background="{TemplateBinding Background}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    SnapsToDevicePixels="True">
       <ContentPresenter Margin="{TemplateBinding Padding}"
                         HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                         VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                         RecognizesAccessKey="True"
                         SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
      </theme:MotifBorderDecorator>
     </Grid>
     <ControlTemplate.Triggers>
      <Trigger Property="IsKeyboardFocused"
               Value="True">
       <Setter Property="Background"
               Value="{StaticResource ThemeActiveBrush}" />
       <Setter Property="Foreground"
               Value="{StaticResource ThemeActiveTextBrush}" />
      </Trigger>
      <Trigger Property="Button.IsDefaulted"
               Value="True">
       <Setter Property="Visibility"
               Value="Visible"
               TargetName="DefaultBorder" />
      </Trigger>
      <Trigger Property="IsPressed"
               Value="true">
       <Setter Property="BorderStyle"
               Value="ThinPressed"
               TargetName="ContentContainer" />
      </Trigger>
      <Trigger Property="ToggleButton.IsChecked"
               Value="true">
       <Setter Property="BorderStyle"
               Value="ThinPressed"
               TargetName="ContentContainer" />
      </Trigger>
      <Trigger Property="IsEnabled"
               Value="False">
       <Setter Property="Foreground"
               Value="{StaticResource ThemeDisabledTextBrush}" />
      </Trigger>
     </ControlTemplate.Triggers>
    </ControlTemplate>
   </Setter.Value>
  </Setter>
 </Style>

 <Style x:Key="{x:Type ToggleButton}"
        BasedOn="{StaticResource BaseButtonStyle}"
        TargetType="{x:Type ToggleButton}" />

 <Style x:Key="{x:Type RepeatButton}"
        BasedOn="{StaticResource BaseButtonStyle}"
        TargetType="{x:Type RepeatButton}">
  <Setter Property="Stylus.IsPressAndHoldEnabled"
          Value="false" />
 </Style>

 <Style x:Key="{x:Type Button}"
        BasedOn="{StaticResource BaseButtonStyle}"
        TargetType="{x:Type Button}" />

 <Style x:Key="ScrollBarLineButtonStyle"
        TargetType="{x:Type RepeatButton}">
  <Setter Property="OverridesDefaultStyle"
          Value="true" />
  <Setter Property="Background"
          Value="{StaticResource ThemeControlBrush}" />
  <Setter Property="Foreground"
          Value="{StaticResource ThemeControlTextBrush}" />
  <Setter Property="BorderBrush"
          Value="{x:Static theme:MotifBorderDecorator.MotifBorderBrush}" />
  <Setter Property="BorderThickness"
          Value="1" />
  <Setter Property="MinWidth"
          Value="0" />
  <Setter Property="MinHeight"
          Value="0" />
  <Setter Property="IsTabStop"
          Value="false" />
  <Setter Property="Focusable"
          Value="false" />
  <Setter Property="Margin"
          Value="0" />
  <Setter Property="Padding"
          Value="0" />
  <Setter Property="Template">
   <Setter.Value>
    <ControlTemplate TargetType="{x:Type RepeatButton}">
     <theme:MotifBorderDecorator x:Name="ClassicBorder"
                                   BorderStyle="ThinRaised"
                                   Width="{TemplateBinding Width}"
                                   Height="{TemplateBinding Height}"
                                   Background="{TemplateBinding Background}"
                                   BorderBrush="{TemplateBinding BorderBrush}"
                                   BorderThickness="{TemplateBinding BorderThickness}">
      <Path HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Fill="{TemplateBinding Foreground}"
            Data="{Binding Path=Content,RelativeSource={RelativeSource TemplatedParent}}" />
     </theme:MotifBorderDecorator>
     <ControlTemplate.Triggers>
      <Trigger Property="IsPressed"
               Value="true">
       <Setter Property="BorderStyle"
               Value="ThinPressed"
               TargetName="ClassicBorder" />
      </Trigger>
      <Trigger Property="IsEnabled"
               Value="false">
       <Setter Property="Foreground"
               Value="{StaticResource ThemeDisabledTextBrush}" />
      </Trigger>
     </ControlTemplate.Triggers>
    </ControlTemplate>
   </Setter.Value>
  </Setter>
 </Style>

 <Style x:Key="HorizontalScrollBarPageButtonStyle"
        TargetType="{x:Type RepeatButton}">
  <Setter Property="OverridesDefaultStyle"
          Value="true" />
  <Setter Property="IsTabStop"
          Value="false" />
  <Setter Property="Focusable"
          Value="false" />
  <Setter Property="MinHeight"
          Value="{StaticResource HorizontalScrollBarHeight}" />
  <Setter Property="MinWidth"
          Value="{StaticResource HorizontalScrollBarButtonWidth}" />
  <Setter Property="Template">
   <Setter.Value>
    <ControlTemplate TargetType="{x:Type RepeatButton}">
     <Rectangle x:Name="PageButtonBackground"
                Fill="Transparent" />
     <ControlTemplate.Triggers>
      <Trigger Property="IsPressed"
               Value="true">
       <Setter Property="Fill"
               Value="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}"
               TargetName="PageButtonBackground" />
      </Trigger>
     </ControlTemplate.Triggers>
    </ControlTemplate>
   </Setter.Value>
  </Setter>
 </Style>

 <Style x:Key="VerticalScrollBarPageButtonStyle"
        TargetType="{x:Type RepeatButton}">
  <Setter Property="OverridesDefaultStyle"
          Value="true" />
  <Setter Property="IsTabStop"
          Value="false" />
  <Setter Property="Focusable"
          Value="false" />
  <Setter Property="MinWidth"
          Value="{StaticResource VerticalScrollBarWidth}" />
  <Setter Property="MinHeight"
          Value="{StaticResource VerticalScrollBarButtonHeight}" />
  <Setter Property="Template">
   <Setter.Value>
    <ControlTemplate TargetType="{x:Type RepeatButton}">
     <Rectangle x:Name="PageButtonBackground"
                Fill="Transparent" />
     <ControlTemplate.Triggers>
      <Trigger Property="IsPressed"
               Value="true">
       <Setter Property="Fill"
               Value="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}"
               TargetName="PageButtonBackground" />
      </Trigger>
     </ControlTemplate.Triggers>
    </ControlTemplate>
   </Setter.Value>
  </Setter>
 </Style>

 <Style x:Key="ScrollBarThumb"
        TargetType="{x:Type Thumb}">
  <Setter Property="Margin"
          Value="0" />
  <Setter Property="Padding"
          Value="0" />
  <Setter Property="Template">
   <Setter.Value>
    <ControlTemplate TargetType="{x:Type Thumb}">
     <theme:MotifBorderDecorator BorderStyle="ThinRaised"
                                   Background="{StaticResource ThemeControlBrush}"
                                   BorderThickness="1"
                                   BorderBrush="{x:Static theme:MotifBorderDecorator.MotifBorderBrush}" />
    </ControlTemplate>
   </Setter.Value>
  </Setter>
 </Style>

 <Style x:Key="{x:Type ScrollBar}"
        TargetType="{x:Type ScrollBar}">
  <Setter Property="Stylus.IsPressAndHoldEnabled"
          Value="false" />
  <Setter Property="Stylus.IsFlicksEnabled"
          Value="false" />
  <Setter Property="Foreground"
          Value="{StaticResource ThemeListTextBrush}" />
  <Setter Property="Background"
          Value="{StaticResource ThemeListBrush}" />
  <Setter Property="BorderBrush"
          Value="{x:Static theme:MotifBorderDecorator.MotifBorderBrush}" />
  <Setter Property="BorderThickness"
          Value="1" />
  <Setter Property="Margin"
          Value="1,0" />
  <Setter Property="Width"
          Value="{StaticResource VerticalScrollBarWidth}" />
  <Setter Property="MinWidth"
          Value="{StaticResource VerticalScrollBarWidth}" />
  <Setter Property="Template">
   <Setter.Value>
    <ControlTemplate TargetType="{x:Type ScrollBar}">
     <Grid>
      <theme:MotifBorderDecorator Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    BorderStyle="ThinPressed" />
      <Grid Margin="{TemplateBinding BorderThickness}">
       <Grid.RowDefinitions>
        <RowDefinition MaxHeight="{StaticResource VerticalScrollBarButtonHeight}" />
        <RowDefinition Height="0.00001*" />
        <RowDefinition MaxHeight="{StaticResource VerticalScrollBarButtonHeight}" />
       </Grid.RowDefinitions>

       <Viewbox Stretch="Fill">
        <RepeatButton Style="{StaticResource ScrollBarLineButtonStyle}"
                      Height="{StaticResource VerticalScrollBarButtonHeight}"
                      MinWidth="{StaticResource VerticalScrollBarWidth}"
                      Command="{x:Static ScrollBar.LineUpCommand}"
                      Content="M 0 4 L 7 4 L 3.5 0 Z" />
       </Viewbox>
       <Rectangle Grid.Row="1"
                  Fill="{StaticResource ThemeListBrush}" />

       <Track Grid.Row="1"
              Name="PART_Track"
              IsDirectionReversed="true">
        <Track.DecreaseRepeatButton>
         <RepeatButton Style="{StaticResource VerticalScrollBarPageButtonStyle}"
                       Command="{x:Static ScrollBar.PageUpCommand}" />
        </Track.DecreaseRepeatButton>
        <Track.IncreaseRepeatButton>
         <RepeatButton Style="{StaticResource VerticalScrollBarPageButtonStyle}"
                       Command="{x:Static ScrollBar.PageDownCommand}" />
        </Track.IncreaseRepeatButton>
        <Track.Thumb>
         <Thumb Style="{StaticResource ScrollBarThumb}" />
        </Track.Thumb>
       </Track>

       <Viewbox Stretch="Fill"
                Grid.Row="2">
        <RepeatButton Style="{StaticResource ScrollBarLineButtonStyle}"
                      Height="{StaticResource VerticalScrollBarButtonHeight}"
                      MinWidth="{StaticResource VerticalScrollBarWidth}"
                      Command="{x:Static ScrollBar.LineDownCommand}"
                      Content="M 0 0 L 3.5 4 L 7 0 Z" />
       </Viewbox>
      </Grid>
     </Grid>
    </ControlTemplate>
   </Setter.Value>
  </Setter>
  <Style.Triggers>
   <Trigger Property="Orientation"
            Value="Horizontal">
    <Setter Property="Margin"
            Value="0,1" />
    <Setter Property="Width"
            Value="Auto" />
    <Setter Property="MinWidth"
            Value="0" />
    <Setter Property="Height"
            Value="{StaticResource HorizontalScrollBarHeight}" />
    <Setter Property="MinHeight"
            Value="{StaticResource HorizontalScrollBarHeight}" />
    <Setter Property="Template">
     <Setter.Value>
      <ControlTemplate TargetType="{x:Type ScrollBar}">
       <Grid>
        <theme:MotifBorderDecorator Background="{TemplateBinding Background}"
                                      BorderBrush="{TemplateBinding BorderBrush}"
                                      BorderThickness="{TemplateBinding BorderThickness}"
                                      BorderStyle="ThinPressed" />
        <Grid Margin="{TemplateBinding BorderThickness}">
         <Grid.ColumnDefinitions>
          <ColumnDefinition MaxWidth="{StaticResource HorizontalScrollBarButtonWidth}" />
          <ColumnDefinition Width="0.00001*" />
          <ColumnDefinition MaxWidth="{StaticResource HorizontalScrollBarButtonWidth}" />
         </Grid.ColumnDefinitions>

         <Viewbox Stretch="Fill">
          <RepeatButton Style="{StaticResource ScrollBarLineButtonStyle}"
                        Width="{StaticResource HorizontalScrollBarButtonWidth}"
                        MinHeight="{StaticResource HorizontalScrollBarHeight}"
                        Command="{x:Static ScrollBar.LineLeftCommand}"
                        Content="M 0 4 L 4 8 L 4 0 Z" />
         </Viewbox>
         <Rectangle Grid.Column="1"
                    Fill="{StaticResource ThemeListBrush}" />
         <Track Grid.Column="1"
                Name="PART_Track">
          <Track.DecreaseRepeatButton>
           <RepeatButton Style="{StaticResource HorizontalScrollBarPageButtonStyle}"
                         Command="{x:Static ScrollBar.PageLeftCommand}" />
          </Track.DecreaseRepeatButton>
          <Track.IncreaseRepeatButton>
           <RepeatButton Style="{StaticResource HorizontalScrollBarPageButtonStyle}"
                         Command="{x:Static ScrollBar.PageRightCommand}" />
          </Track.IncreaseRepeatButton>
          <Track.Thumb>
           <Thumb Style="{StaticResource ScrollBarThumb}" />
          </Track.Thumb>
         </Track>


         <Viewbox Stretch="Fill"
                  Grid.Column="2">
          <RepeatButton Style="{StaticResource ScrollBarLineButtonStyle}"
                        Width="{StaticResource HorizontalScrollBarButtonWidth}"
                        MinHeight="{StaticResource HorizontalScrollBarHeight}"
                        Command="{x:Static ScrollBar.LineRightCommand}"
                        Content="M 0 0 L 0 8 L 4 4 Z" />
         </Viewbox>
        </Grid>
       </Grid>
      </ControlTemplate>
     </Setter.Value>
    </Setter>
   </Trigger>
  </Style.Triggers>
 </Style>

 <Style x:Key="{x:Type ScrollViewer}"
        TargetType="{x:Type ScrollViewer}"
        BasedOn="{StaticResource BaseFrameworkElementStyle}">
  <Setter Property="Background"
          Value="{StaticResource ThemeControlBrush}" />
  <Style.Triggers>
   <Trigger Property="IsEnabled"
            Value="false">
    <Setter Property="Foreground"
            Value="{StaticResource ThemeDisabledTextBrush}" />
   </Trigger>
  </Style.Triggers>
 </Style>

 <Style x:Key="CheckRadioFocusVisual">
  <Setter Property="Control.Template">
   <Setter.Value>
    <ControlTemplate>
     <Rectangle Margin="14,0,0,0"
                StrokeThickness="1"
                Stroke="{StaticResource ThemeControlTextBrush}"
                StrokeDashArray="1 2"
                SnapsToDevicePixels="true" />
    </ControlTemplate>
   </Setter.Value>
  </Setter>
 </Style>

 <Style x:Key="{x:Type RadioButton}"
        TargetType="{x:Type RadioButton}"
        BasedOn="{StaticResource BaseFrameworkElementStyle}">
  <Setter Property="FocusVisualStyle"
          Value="{StaticResource CheckRadioFocusVisual}" />
  <Setter Property="Foreground"
          Value="{StaticResource ThemeControlTextBrush}" />
  <Setter Property="Background"
          Value="{StaticResource ThemeControlBrush}" />
  <Setter Property="Padding"
          Value="2,0,0,0" />
  <Setter Property="Template">
   <Setter.Value>
    <ControlTemplate TargetType="{x:Type RadioButton}">
     <BulletDecorator Background="Transparent">
      <BulletDecorator.Bullet>
       <theme:MotifBorderDecorator x:Name="Border"
                                     Width="13"
                                     Height="13"
                                     BorderStyle="RadioButton"
                                     Background="{TemplateBinding Background}"
                                     BorderThickness="4,4,5,5">
        <Ellipse x:Name="Dot"
                 Visibility="Hidden"
                 Fill="{TemplateBinding Foreground}"
                 Width="4"
                 Height="4" />
       </theme:MotifBorderDecorator>
      </BulletDecorator.Bullet>
      <ContentPresenter Margin="{TemplateBinding Padding}"
                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                        RecognizesAccessKey="True" />
     </BulletDecorator>
     <ControlTemplate.Triggers>
      <Trigger Property="IsChecked"
               Value="true">
       <Setter TargetName="Dot"
               Property="Visibility"
               Value="Visible" />
      </Trigger>
      <Trigger Property="IsPressed"
               Value="true">
       <Setter TargetName="Border"
               Property="Background"
               Value="{StaticResource ThemeListBrush}" />
      </Trigger>
      <Trigger Property="IsEnabled"
               Value="false">
       <Setter TargetName="Border"
               Property="Background"
               Value="{StaticResource ThemeControlBrush}" />
       <Setter TargetName="Dot"
               Property="Fill"
               Value="{StaticResource ThemeDisabledTextBrush}" />
       <Setter Property="Foreground"
               Value="{StaticResource ThemeDisabledTextBrush}" />
      </Trigger>
     </ControlTemplate.Triggers>
    </ControlTemplate>
   </Setter.Value>
  </Setter>
 </Style>

 <Style x:Key="{x:Type CheckBox}"
        TargetType="{x:Type CheckBox}"
        BasedOn="{StaticResource BaseFrameworkElementStyle}">
  <Setter Property="FocusVisualStyle"
          Value="{StaticResource CheckRadioFocusVisual}" />
  <Setter Property="Foreground"
          Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" />
  <Setter Property="Background"
          Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" />
  <Setter Property="BorderBrush"
          Value="{x:Static theme:MotifBorderDecorator.MotifBorderBrush}" />
  <Setter Property="BorderThickness"
          Value="2" />
  <Setter Property="Padding"
          Value="2,0,0,0" />
  <Setter Property="FocusVisualStyle"
          Value="{StaticResource EmptyCheckBoxFocusVisual}" />
  <Setter Property="Template">
   <Setter.Value>
    <ControlTemplate TargetType="{x:Type CheckBox}">
     <BulletDecorator Background="Transparent"
                      SnapsToDevicePixels="true">
      <BulletDecorator.Bullet>
       <theme:MotifBorderDecorator x:Name="CheckMark"
                                     BorderStyle="Sunken"
                                     Background="{TemplateBinding Background}"
                                     BorderThickness="{TemplateBinding BorderThickness}"
                                     BorderBrush="{TemplateBinding BorderBrush}">
        <Path x:Name="CheckMarkPath"
              Margin="1,1,1,1"
              Width="7"
              Height="7"
              FlowDirection="LeftToRight"
              Fill="{TemplateBinding Foreground}"
              Data="M 0 2.0 L 0 4.8 L 2.5 7.4 L 7.1 2.8 L 7.1 0 L 2.5 4.6 Z" />
       </theme:MotifBorderDecorator>
      </BulletDecorator.Bullet>
      <ContentPresenter Margin="{TemplateBinding Padding}"
                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                        RecognizesAccessKey="True"
                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
     </BulletDecorator>
     <ControlTemplate.Triggers>
      <Trigger Property="IsChecked"
               Value="false">
       <Setter TargetName="CheckMarkPath"
               Property="Visibility"
               Value="Hidden" />
      </Trigger>
      <Trigger Property="IsChecked"
               Value="{x:Null}">
       <Setter TargetName="CheckMark"
               Property="Background"
               Value="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}" />
       <Setter TargetName="CheckMarkPath"
               Property="Fill"
               Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" />
      </Trigger>
      <Trigger Property="IsPressed"
               Value="true">
       <Setter TargetName="CheckMark"
               Property="Background"
               Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
      </Trigger>
      <Trigger Property="IsEnabled"
               Value="false">
       <Setter TargetName="CheckMark"
               Property="Background"
               Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
       <Setter TargetName="CheckMarkPath"
               Property="Fill"
               Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
       <Setter Property="Foreground"
               Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
      </Trigger>
     </ControlTemplate.Triggers>
    </ControlTemplate>
   </Setter.Value>
  </Setter>
 </Style>

 <BorderGapMaskConverter x:Key="BorderGapMaskConverter" />
 <Style x:Key="{x:Type GroupBox}"
        TargetType="{x:Type GroupBox}"
        BasedOn="{StaticResource BaseFrameworkElementStyle}">
  <Setter Property="BorderBrush"
          Value="{x:Static theme:MotifBorderDecorator.MotifBorderBrush}" />
  <Setter Property="BorderThickness"
          Value="2" />
  <Setter Property="Template">
   <Setter.Value>
    <ControlTemplate TargetType="{x:Type GroupBox}">
     <Grid SnapsToDevicePixels="true">
      <Grid.ColumnDefinitions>
       <ColumnDefinition Width="6" />
       <ColumnDefinition Width="Auto" />
       <ColumnDefinition Width="*" />
       <ColumnDefinition Width="6" />
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
       <RowDefinition Height="Auto" />
       <RowDefinition Height="Auto" />
       <RowDefinition Height="*" />
       <RowDefinition Height="6" />
      </Grid.RowDefinitions>
      <Border Grid.Row="1"
              Grid.RowSpan="3"
              Grid.Column="0"
              Grid.ColumnSpan="4"
              BorderThickness="{TemplateBinding BorderThickness}"
              BorderBrush="Transparent"
              Background="{TemplateBinding Background}" />
      <Border x:Name="Header"
              Padding="3,0,3,0"
              Grid.Row="0"
              Grid.RowSpan="2"
              Grid.Column="1">
       <ContentPresenter ContentSource="Header"
                         RecognizesAccessKey="True"
                         SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
      </Border>
      <ContentPresenter Grid.Row="2"
                        Grid.Column="1"
                        Grid.ColumnSpan="2"
                        Margin="{TemplateBinding Padding}"
                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
      <theme:MotifBorderDecorator Grid.Row="1"
                                    Grid.RowSpan="3"
                                    Grid.ColumnSpan="4"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderStyle="Etched">
       <theme:MotifBorderDecorator.OpacityMask>
        <MultiBinding Converter="{StaticResource BorderGapMaskConverter}"
                      ConverterParameter="7">
         <Binding ElementName="Header"
                  Path="ActualWidth" />
         <Binding RelativeSource="{RelativeSource Self}"
                  Path="ActualWidth" />
         <Binding RelativeSource="{RelativeSource Self}"
                  Path="ActualHeight" />
        </MultiBinding>
       </theme:MotifBorderDecorator.OpacityMask>
      </theme:MotifBorderDecorator>
     </Grid>
    </ControlTemplate>
   </Setter.Value>
  </Setter>
 </Style>


</ResourceDictionary>